//
//  Emoticon.swift
//  EmoticonKeyBoard
//
//  Created by Arvin on 15/11/20.
//  Copyright © 2015年 Arvin. All rights reserved.
//

import UIKit

class Emoticon: NSObject {
    // 表情中文
    var chs: String?
    // 表情图片
    var png: String?
    var imagePng: UIImage? {
        if png != nil {
            // 注意: 这里的路径获取方式, 是bundlePath
            let path = NSBundle.mainBundle().bundlePath + "/Emoticons.bundle/"+"\(id!)"+"/\(png!)"
            let image = UIImage(contentsOfFile: path)
            return image
        }
        return nil
    }
    
    // 表情16进制字符串
    var code: String?
    // 将code转成系统表情 计算性属性
    var codeStr: String? {
        return code?.emojiString
    }
    
    // 表情包文件名
    var id: String?
    
    var isEmpty = false
    var isDelete = false
    
    init(id: String?, dict: [String: String]?) {
        self.id = id
        super.init()
        
        guard let dic = dict else {
            return
        }

        self.setValuesForKeysWithDictionary(dic)
    }
    
    init(empty: Bool) {
        self.isEmpty = empty
        super.init()
    }
    
    init(delete: Bool) {
        self.isDelete = delete
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    
}
